package maiyatian.videolive.fragment.setting;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import maiyatian.videolive.common.ConstentInfo;
import maiyatian.videolive.IActivity;
import maiyatian.videolive.IFragment;
import maiyatian.videolive.R;
import maiyatian.videolive.activity.SettingActivity;
import maiyatian.videolive.activity.WebviewActivity;

/**
 * Created by 王中阳 on 2016/5/10.
 */
@ContentView(R.layout.content_aboutus)
public class AboutUsFragment extends IFragment implements View.OnClickListener {
    public static final String TAG = "AboutUsFragment";
    SettingActivity mycontext;
    @ViewInject(R.id.communityConvention)
    RelativeLayout communityConventionp;
    @ViewInject(R.id.privacyPolicy)
    RelativeLayout privacyPolicy;
    @ViewInject(R.id.serviceTerms)
    RelativeLayout serviceTerms;
    @ViewInject(R.id.contactUs)
    RelativeLayout contactUs;

    public AboutUsFragment() {

    }

    public static AboutUsFragment newInstance() {
        AboutUsFragment fragment = new AboutUsFragment();
        return fragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.mycontext = (SettingActivity) context;

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return x.view().inject(this, inflater, container);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initClick();
    }

    private void initClick() {
        communityConventionp.setOnClickListener(this);
        privacyPolicy.setOnClickListener(this);
        serviceTerms.setOnClickListener(this);
        contactUs.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()) {
            case R.id.communityConvention:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra(IActivity.PAGETO, ConstentInfo.ABOUT_COMMUNITYCONVENTION);
                break;
            case R.id.privacyPolicy:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra(IActivity.PAGETO,ConstentInfo.ABOUT_PRIVACYPOLICY);
                break;
            case R.id.serviceTerms:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra(IActivity.PAGETO,ConstentInfo.ABOUT_SERVICETRRMS);
                break;
            case R.id.contactUs:
                intent.setClass(getActivity(), WebviewActivity.class);
                intent.putExtra(IActivity.PAGETO,ConstentInfo.ABOUT_CONTACTUS);
                break;
        }
        mycontext.startActivity(intent);
    }
}
